﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace ThreeDI.Common.Serilization
{
    public static class SerilizationHelper
    {
        public static void Serilize<T>(this T obj, string path)
        {
            var writter = File.OpenWrite(path);
            XmlSerializer serilizer = new XmlSerializer(typeof(T));
            serilizer.Serialize(writter, obj);
            writter.Close();
        }
       public static T deSerilize<T>(this T obj, string path)
       {
           T type;
            XmlSerializer serializer = new XmlSerializer(typeof(T));
           FileStream fileStream = new FileStream(path,FileMode.Open);
           type = (T)serializer.Deserialize(fileStream);
           return type;
       }
    }

}
